package com.lagou.edu.blog.controller;

import com.lagou.edu.blog.pojo.Article;
import com.lagou.edu.blog.service.IArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

/**
 * @ProjectName: s1-4
 * @Title: ArticleController
 * @Package: com.lagou.edu.blog.controller
 * @Description: Index Controller
 * @author: Ian
 * @date: 27/12/2020 9:10 PM
 * @version: V1.0.0
 */
@Controller
public class IndexController {
    @Autowired
    private IArticleService articleService;

    @RequestMapping("/index")
    public String index(Model model, Pageable page) {
        Page<Article> pageResult = articleService.findAll(page);
        model.addAttribute("page", pageResult);

        return "client/index";
    }

}
